#include "stdafx.h"
#include "AVEncode.h"
#include "DVR_Enc.h"

TGERR_CODE  __stdcall DVR_Enc_Open(int nSrcWidth,int nSrcHeight,DVR_PAR264* par,ChatEncodeCallBack funCallBack,DWORD dwContext,void* pContext,HANDLE &hEncoder)
{
	TGERR_CODE ret = TG_ERR_SUCCESS ;
	CAVEncode *pEnc = new CAVEncode;
	if( (ret=pEnc->Init(nSrcWidth,nSrcHeight,par,funCallBack,dwContext,pContext)) == TG_ERR_SUCCESS )
 		hEncoder = (HANDLE)pEnc;
	else
		delete pEnc ;
 	return ret;
}

TGERR_CODE  __stdcall DVR_Enc_Audio(HANDLE hEncoder,DWORD lTimestamp,BYTE* pSrcData,long lSrcLen)
{
	CAVEncode *pEnc = (CAVEncode *)hEncoder;
	return pEnc->Audio(lTimestamp, pSrcData,lSrcLen) ;
}
TGERR_CODE  __stdcall DVR_Enc_SetPar264(HANDLE hEncoder,DVR_PAR264* par)
{
	CAVEncode *pEnc = (CAVEncode *)hEncoder;
	return pEnc->SetPar264(par) ;
}
TGERR_CODE  __stdcall DVR_Enc_Video(HANDLE hEncoder,DWORD lTimestamp,unsigned char *pYUV,int ySize,int uSize,int vSize)
{
	CAVEncode *pEnc = (CAVEncode *)hEncoder;
	return pEnc->Video(lTimestamp,pYUV, ySize, uSize, vSize) ;
}

void __stdcall DVR_Enc_Close(HANDLE hEncoder)
{
	CAVEncode *pEnc = (CAVEncode *)hEncoder;
	pEnc->Release();
	delete pEnc ;
	pEnc = NULL ;
	return  ;
}


